package com.bestcem.xm.ticket.controller.param.ticket;

import com.bestcem.xm.ticket.controller.param.ticket.config.NotifyConfigParam;
import com.bestcem.xm.ticket.controller.param.ticket.notify.setting.UpdateSettingParam;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

/**
 * @author liheng
 * @version v1.0
 * @date 2021/9/6 14:52
 */
@Data
public class InsertTicketParam {

    private String name;

    @JsonProperty(value = "detail_template_id")
    private String detailTemplateId;

    /**
     * z组织id，后端传递到service时设置的
     */
    private String orgId;

    /**
     * userId
     */
    private String userId;

    /**
     * 通知配置id
     */
    private List<String> ticketNotifyConfigIds;

    /**
     * 配置id
     */
    private String ticketConfigId;

    @JsonProperty(value = "template_detail_fields")
    private List<TemplateField> templateDetailFields;

    @JsonProperty(value = "handle_template_id")
    private String handleTemplateId;

    @JsonProperty(value = "notify_ways")
    private UpdateSettingParam.Way notifyWays;

    @JsonProperty(value = "follow_config")
    private FollowConfig followConfig;

    @JsonProperty(value = "notify_handler")
    private Boolean notifyHandler;

    @JsonProperty(value = "cc_list")
    private List<UserInfo> ccList;

    /**
     * 创建工单的用户姓名
     */
    @JsonIgnore
    private String username;

    /**
     * 邮箱id
     * 2022-02-24 消息库2.0 新增字段
     */
    @JsonProperty(value = "smtp_id")
    private String smtpId;


    /**
     * 通知配置
     * 2022-02-24 消息库2.0 新增字段
     */
    @JsonProperty(value = "ticket_notify_config_list")
    private List<NotifyConfigParam> ticketNotifyConfigList;

    @NoArgsConstructor
    @AllArgsConstructor
    @Data
    public static class UserInfo implements Serializable {
        private static final long serialVersionUID = 8339343757039550028L;
        @JsonProperty(value = "user_id")
        private String userId;

        /**
         * 用户过滤 0-按层级过滤，1-按用户过滤
         */
        @JsonProperty(value = "user_filter")
        private Integer userFilter;

        @JsonProperty(value = "region_id")
        private String regionId;

        @JsonProperty(value = "role_id")
        private String roleId;
    }

    @NoArgsConstructor
    @AllArgsConstructor
    @Data
    public static class FollowConfig implements Serializable {

        private static final long serialVersionUID = 3191321297897686361L;
        @JsonProperty(value = "user_id")
        private String userId;

        private String name;

        private String email;

        /**
         * 用户过滤 0-按层级过滤，1-按用户过滤
         */
        @JsonProperty(value = "user_filter")
        private Integer userFilter;

        @JsonProperty(value = "region_id")
        private String regionId;

        @JsonProperty(value = "role_id")
        private String roleId;

        @JsonProperty(value = "role_name")
        private String roleName;
    }

    @NoArgsConstructor
    @AllArgsConstructor
    @Data
    public static class TemplateField implements Serializable {

        private static final long serialVersionUID = 4765825414471777763L;
        /**
         * 详情模板中的显示内容
         */
        private String name;

        /**
         * 答案
         */
        private String answer;

        /**
         * 选项类型
         * text--1单行文本； multiLine--2 多行文本； select---3单选； cascadeSelect--4 级联选择
         */
        private Integer type;

        /**
         * 是否必传
         */
        private Boolean required;

        /**
         * 数据来源,联系人3.0、p2新增
         * 1-自定义数据，2-系统问卷数据 3-系统联系人数据
         */
//        private Integer source;

        /**
         * 联系人id，联系人3.0、p2新增
         */
        @JsonProperty("member_id")
        private String memberId;
    }
}
